import {
	setStorageSync,
	getStorageSync
} from '@/utils/storage.js'
const settingModules = {
	state: {
		readThemeObject: {
			light: {
				name: 'day',
				item: '日间',
				icon: 'day',
				tabbarBackground:'#ffffff', // 菜单背景色
				mainBackground:'#ffedd9', // 主背景色
				defaultBackground:'#fff9f2',// 常规背景
				tipsBackground:'#f5f8fc', // 次要背景色
				placeholderBackground:'#f2f2f2', // 占位背景色
				mainColor:'#303133', // 主要文字颜色
				defaultColor:'#606266', // 常规颜色
				tipsColor:'#bfbfbf', // 次要颜色
				placeholderColor:'#909399', // 占位颜色
				bannerBackground:'rgba(0, 38, 107, .3)' // banner遮罩层
			},
			dark: {
				name: 'night',
				item: '夜间',
				icon: 'night',
				tabbarBackground:'#0c0e14', // 菜单背景色
				mainBackground:'#0c0e14', // 主背景色
				defaultBackground:'#10121a',// 常规背景
				tipsBackground:'#1E242E', // 次要背景色
				placeholderBackground:'#606266', // 占位背景色
				mainColor:'#d2dbff', // 主要文字颜色
				defaultColor:'#ffffff', // 常规颜色
				tipsColor:'#bfbfbf', // 次要颜色
				placeholderColor:'#bfbfbf', // 占位颜色
				bannerBackground:'rgba(17, 17, 17, .7)' // banner遮罩层
			}
		},
		readSetting: getStorageSync('readSetting') || {
			fontSize: 16,
			fontFamily: 'font-kaiti',
			pagePadding: '20',
			sectionDistance: '1',
			lineDistance: '38',
			openLastRead: false,
			lightForever: false,
			isDarkMode: false
		}
	},
	getters: {
		readTheme:  state => state.readThemeObject[state.readSetting.isDarkMode ? 'dark' : 'light']
	},
	mutations: {
		SET_READ_SETTING(state, {
			key,
			value
		}) {
			state.readSetting[key] = value
			setStorageSync('readSetting', state.readSetting)
		},
		UPDATE_READ_SETTING(state) {
			setStorageSync('readSetting', state.readSetting)
		}
	}
}

export default settingModules
